<?php
/**
 * WQPHP封装工具类，仅供学习研究使用，禁止任何形式的转载发布
 * User: Jessica@aweb.wang
 * Date: 2023/3/10 14:50
 * Email: <1194323013@qq.com>
 *                            _ooOoo_
 *                           o8888888o
 *                           88" . "88
 *                           (| -_- |)
 *                           O\  =  /O
 *                        ____/`---'\____
 *                      .'  \\|     |//  `.
 *                     /  \\|||  :  |||//  \
 *                    /  _||||| -:- |||||-  \
 *                    |   | \\\  -  /// |   |
 *                    | \_|  ''\---/''  |   |
 *                    \  .-\__  `-`  ___/-. /
 *                  ___`. .'  /--.--\  `. . __
 *               ."" '<  `.___\_<|>_/___.'  >'"".
 *              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 *              \  \ `-.   \_ __\ /__ _/   .-` /  /
 *         ======`-.____`-.___\_____/___.-`____.-'======
 *                            `=---='
 *        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 *                      Buddha Bless, No Bug !
 **/

namespace app\common\utils;
use GatewayClient\Gateway;

class SocketUtils
{
    //绑定用户ID和客户端ID
    public function bindClientIdToMemberId($memberId, $clientId)
    {
        Gateway::$registerAddress = "127.0.0.1:1238";
        Gateway::bindUid($clientId, $memberId);
    }
    //向用户ID发送信息
    public function sendToUser($userId, $message)
    {
        Gateway::$registerAddress = "127.0.0.1:1238";
        Gateway::sendToUid($userId, $message);
    }

    //向用户clientCode发送信息
    public function sendToUserCode($code, $message)
    {
        Gateway::$registerAddress = '127.0.0.1:1238';
        Gateway::sendToClient($code, $message);
    }
}